// import React, { useState } from 'react';
// import { Button, Modal } from 'antd';

// function DEL({delmodel,delItem,closeDel,delIndex,deltype,dispatch}:any) {

//   const handleOk = () => {
//     closeDel(false)
//     console.log(deltype)
//     if(deltype === 1){
//         dispatch({type:'offslaes/DELOFFSALES',payload:delIndex})
//     }
//   };

//   const handleCancel = () => {
//     closeDel(false)
//   };
//   return (
//     <div>
//          <Modal title="Basic Modal" open={delmodel} onOk={handleOk} onCancel={handleCancel}>
//             你确定要删除<span style={{color:'#099'}}>{delItem}</span>么
//       </Modal>
//     </div>
//   )
// }

// export default DEL

import React, { useState } from 'react';
import { Button, Modal } from 'antd';
import { connect } from 'react-redux';

export const DEL = ({
  delmodel,
  delItem,
  closeDel,
  delIndex,
  deltype,
  dispatch,
}: any) => {
  const handleOk = () => {
    closeDel(false);
    // console.log(deltype);
    if (deltype === 1) {
      dispatch({ type: 'offslaes/DELOFFSALES', payload: delIndex });
    } else if (deltype === 2) {
      dispatch({ type: 'offslaes/DELOFFHIRE', payload: delIndex });
    } else if (deltype === 3) {
      dispatch({ type: 'offslaes/DELOSHOPSALES', payload: delIndex });
    } else if (deltype === 4) {
      dispatch({ type: 'offslaes/DELOSHOPHIRE', payload: delIndex });
    }
  };

  const handleCancel = () => {
    closeDel(false);
  };
  return (
    <div>
      <div>
        <Modal
          title="Basic Modal"
          open={delmodel}
          onOk={handleOk}
          onCancel={handleCancel}
        >
          你确定要删除<span style={{ color: '#099' }}>{delItem}</span>么
        </Modal>
      </div>
    </div>
  );
};

const mapStateToProps = ({
  offslaes: { offsldata, offhiredata, shopsalesdata, shophiredata },
}: any) => {
  return {
    offsldata,
    offhiredata,
    shopsalesdata,
    shophiredata,
  };
};

export default connect(mapStateToProps)(DEL);
